//
//  JLResetPwdViewController.m
//  JLStyleApp
//
//  Created by LvJianfeng on 15/8/20.
//  Copyright (c) 2015年 JLStyle. All rights reserved.
//

#import "JLResetPwdViewController.h"

@interface JLResetPwdViewController ()
@property (weak, nonatomic) UITextField *phoneTextField;
@property (strong, nonatomic) UIButton *nextButton;
@end

@implementation JLResetPwdViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"修改密码";
    self.view.backgroundColor = [UIColor customControllerBackgroundColor];
    
    [self setupUI];
    
    [self.view addSubview:self.nextButton];
}

- (void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
    [self.phoneTextField becomeFirstResponder];
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self.navigationController.navigationBar setCustomBackgroundColor:GlobalColor];
    
}

- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    [self.phoneTextField resignFirstResponder];
}

- (void)nextAction{
    if (isNullString(self.phoneTextField.text) || ![JFGlobalInstance validateNumber:self.phoneTextField.text]) {
        [JFGlobalInstance showAlertLabel:self.navigationController.view text:@"(%>_<%)请输入手机号码." afterDelay:2.f];
        return;
    }
}

//配置界面
- (void)setupUI{
    UITextField *phoneTextField = [[UITextField alloc] initWithFrame:CGRectMake(0, 84, ScreenWidth, 50)];
    phoneTextField.backgroundColor = [UIColor whiteColor];
    phoneTextField.leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 0)];
    phoneTextField.leftViewMode = UITextFieldViewModeAlways;
    phoneTextField.placeholder = @"手机号码";
    phoneTextField.keyboardType = UIKeyboardTypePhonePad;
    [self.view addSubview:phoneTextField];
    self.phoneTextField = phoneTextField;
}

//- (void)setupRightBarItem{
//    UIButton *doneButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 50, 20)];
//    doneButton.titleLabel.font = JLFont(15);
//    [doneButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
//    [doneButton setTitleColor:[UIColor customLightPlaceColor] forState:UIControlStateHighlighted];
//    [doneButton setTitle:@"下一步" forState:UIControlStateNormal];
//    [doneButton addTarget:self action:@selector(nextAction) forControlEvents:UIControlEventTouchUpInside];
//    UIBarButtonItem *rightBarItem = [[UIBarButtonItem alloc] initWithCustomView:doneButton];
//    self.navigationItem.rightBarButtonItem = rightBarItem;
//}

#pragma mark lazyload
- (UIButton *)nextButton{
    if (_nextButton==nil) {
        CGFloat registerButtonW = ScreenWidth-40;
        _nextButton = [[UIButton alloc] initWithFrame:CGRectMake(ScreenWidth/2-registerButtonW/2, self.phoneTextField.center.y+25+50, registerButtonW, 50)];
        _nextButton.titleLabel.textColor = [UIColor whiteColor];
        _nextButton.backgroundColor = GlobalColor;
        _nextButton.titleLabel.font = JLBlodFont(18);
        _nextButton.layer.cornerRadius = 25;
        [_nextButton setTitle:@"下一步" forState:UIControlStateNormal];
        
        [_nextButton addTarget:self action:@selector(nextAction) forControlEvents:UIControlEventTouchUpInside];
    }
    return _nextButton;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
